//这是文章详情页面的请求函数处理文件



const {Article} = require('../../model/article');
const {Comment} = require('../../model/comment');

module.exports=async (req,res)=>{
	//接收客户端传递过来的文章id值
	const id = req.query.id;
	//根据id查询文章详细信息
	let article = await Article.findOne({_id:id}).populate('author');

	//查询当前文章所对应的评论信息
	let comments = await Comment.find({aid:id}).populate('uid');

	

	article = JSON.stringify(article);
	article = JSON.parse(article);

	comments = JSON.stringify(comments);
	comments = JSON.parse(comments);


	res.render('home/article.art',{
		article:article,
		comments:comments
	})
}